//
//  demoCell.swift
//  Practice
//
//  Created by miaozhihui on 2017/2/9.
//  Copyright © 2017年 DeKuTree. All rights reserved.
//

import UIKit

class demoCell: UITableViewCell {
    
    /// 顶部分割视图
    fileprivate lazy var topView = UIView(bgColor: UIColor.xs_color(withHex: 0xf2f2f2))
    
    /// 头像
    fileprivate lazy var iconView = UIImageView()
    
    /// 姓名
    fileprivate lazy var nameLabel = UILabel(title: "", fontSize: 13, color: UIColor.xs_color(withHex: 0xf33e00), isCenter: false)
    
    /// 会员
    fileprivate lazy var memberIconView = UIImageView(imageName: "common_icon_membership")
    
    /// 时间
    fileprivate lazy var timeLabel = UILabel(title: "", fontSize: 10, color: UIColor.xs_color(withHex: 0xff6c00), isCenter: false)
    
    /// 来源
    fileprivate lazy var sourceLabel = UILabel(title: "", fontSize: 10, color: UIColor.xs_color(withHex: 0x828282), isCenter: false)
    
    /// 认证图标
    fileprivate lazy var vipIconView = UIImageView(imageName: "avatar_vip")
    
    /// 微博正文
    lazy var statusLabel = UILabel(title: "", fontSize: 13, color: UIColor.black, isCenter: false)
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}

// MARK: - 设置界面
extension demoCell {
    
    /// 设置界面
    fileprivate func setupUI() {
        contentView.addSubview(topView)
        contentView.addSubview(iconView)
        contentView.addSubview(nameLabel)
        contentView.addSubview(memberIconView)
        contentView.addSubview(timeLabel)
        contentView.addSubview(sourceLabel)
        contentView.addSubview(vipIconView)
        contentView.addSubview(statusLabel)
        topView.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(8)
        }
        iconView.snp.makeConstraints { (make) in
            make.top.equalTo(topView.snp.bottom).offset(12)
            make.left.equalToSuperview().offset(11)
            make.width.height.equalTo(34)
        }
        nameLabel.snp.makeConstraints { (make) in
            make.top.equalTo(iconView.snp.top).offset(4)
            make.left.equalTo(iconView.snp.right).offset(11)
        }
        memberIconView.snp.makeConstraints { (make) in
            make.centerY.equalTo(nameLabel)
            make.left.equalTo(nameLabel.snp.right).offset(4)
        }
        timeLabel.snp.makeConstraints { (make) in
            make.left.equalTo(nameLabel)
            make.bottom.equalTo(iconView)
        }
        sourceLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(timeLabel)
            make.left.equalTo(timeLabel.snp.right).offset(8)
        }
        vipIconView.snp.makeConstraints { (make) in
            make.centerY.equalTo(iconView.snp.bottom)
            make.centerX.equalTo(iconView.snp.right)
        }
        statusLabel.snp.makeConstraints { (make) in
            make.top.equalTo(iconView.snp.bottom).offset(11)
            make.left.equalTo(iconView)
            make.right.lessThanOrEqualToSuperview().offset(-11)
            make.bottom.lessThanOrEqualToSuperview().offset(-12)
        }
    }
}
